﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;

namespace SheepClock
{
    public partial class ColorListItem : UserControl
    {
        public ColorListItem()
        {
            InitializeComponent();
        }

        public ColorListItem(string text, Color color)
            : this()
        {
            ColorTitle.Text = text;
            //ColorTitle.Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 0, 0, 0));
            ColorRectangle.Fill = new System.Windows.Media.SolidColorBrush(color);
        }

        public ColorListItem(string text, string imagePath)
            : this()
        {
            ColorTitle.Text = text;
            //ColorTitle.Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 0, 0, 0));

            //System.Windows.Media.ImageBrush wpImageBrush = new System.Windows.Media.ImageBrush();
            //wpImageBrush.ImageSource = new BitmapImage(new Uri(imagePath, UriKind.Relative));

            //ColorRectangle.Fill = Application.Current.Resources["PhoneContrastBackgroundBrush"] as System.Windows.Media.SolidColorBrush;
            //ColorRectangle.OpacityMask = wpImageBrush;

            ColorRectangle.Visibility = Visibility.Collapsed;
            imageColorRectangle.Visibility = Visibility.Visible;
        }

        private bool mSelected = false;
        public bool Selected
        {
            get
            {
                return mSelected;
            }
            set
            {
                if (value)
                    ColorTitle.Foreground = Application.Current.Resources["PhoneAccentBrush"] as System.Windows.Media.SolidColorBrush;
                else
                    ColorTitle.Foreground = Application.Current.Resources["PhoneContrastForegroundBrush"] as System.Windows.Media.SolidColorBrush;
                mSelected = value;
            }
        }

    }
}